<template>
  <div class="app-container">
    <el-tabs v-model="listQuery.type" type="card" style="margin-bottom:10px">
      <el-tab-pane v-for="item in typeJson" :key="item.value" :label="item.label" :name="item.value">
      </el-tab-pane>
    </el-tabs>
    <div class="filter-container">
      <el-input v-model="listQuery.name$lk" placeholder="产品名称" class="filter-item" />
      <div class="filter-item">
        <div class="searchItem">
          <span class="searchLabel">交易时间：</span>
          <DatePicker :mode="1" :startDate.sync="listQuery.createTime$gte" :endDate.sync="listQuery.createTime$lte"
            clearable />
        </div>
      </div>
      <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter"
        >
        查询
      </el-button>
    </div>
    <el-table v-loading="listLoading" :data="list" border fit highlight-current-row row-key="id" style="width: 100%;">
      <el-table-column label="序号" type="index" align="center" width="60px" />
      <!-- <el-table-column label="序号" prop="sequence" align="center" width="60px" /> -->
      <el-table-column label="产品名称" prop="name" align="center" />
      <el-table-column label="产品类别" prop="categoryName" align="center" />
      <el-table-column label="交易类型" prop="typeText" align="center" />
      <!-- <el-table-column label="编号" prop="identifier" align="center" /> -->
      <el-table-column label="交易数量" prop="num" align="center" />
      <el-table-column label="交易金额" prop="amount" align="center" />
      <el-table-column label="交易时间" prop="date" align="center" />
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="listQuery.pageNo" :limit.sync="listQuery.pageSize"
      @pagination="getList" />

  </div>
</template>

<script>
import { report1 } from '@/api/report'
import waves from '@/directive/waves' // waves directive
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import Cascader from '@/components/Cascader'
import DatePicker from '@/components/DatePicker'

export default {
  name: 'report1',
  directives: { waves },
  components: { Cascader, Pagination, DatePicker },
  props: {
    type: {
      type: Number,
      default: 1
    }
  },
  data() {
    return {
      list: [],
      total: 0,
      listLoading: true,
      listQuery: {
        pageNo: 1,
        pageSize: 20,
        type: '1',
        createTime$gte: '',
        createTime$lte: '',
        name$lk: '',
      },
      multipleSelection: [],
      props: { value: 'id', label: 'name' },
      typeJson: [
        { value: '1', label: '商城交易' },
        { value: '10', label: '集采采购' },
        { value: '11', label: '挂牌交易' },
        { value: '12', label: '竞价交易' },
      ],
    }
  },
  watch: {
    'listQuery.type': function () {
      this.handleFilter()
    }
  },
  created() {
    // this.listQuery.type = this.type
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      report1(this.listQuery).then(response => {
        this.list = response.list || []
        this.total = response.totalCount
        this.listLoading = false
      })
    },
    handleFilter() {
      this.listQuery.pageNo = 1
      this.getList()
    },
  }
}
</script>

<style lang="scss" scoped>
.searchItem {
  display: flex;
  align-items: center;
  .searchLabel {
    color: #666;
  }
}
</style>